package com.moli.iov.down.command.design.strategy.commandreqdto.impl;

import com.moli.iov.down.enums.command.CommandEnum;
import com.moli.iov.down.enums.OperateTypeEnum;
import com.moli.iov.down.enums.command.RemoteControlEnum;
import com.moli.iov.down.enums.command.extend.ExtendWindowEnum;
import com.moli.iov.down.model.dto.remoting.CommandDto;
import com.moli.iov.down.model.dto.remoting.CommandReqDto;
import com.moli.iov.down.command.design.strategy.commandreqdto.CommandReqDtoStrategy;

/**
 * <p>
 * 车窗控制:0x00 升窗； 0x01 降窗； 0x03:停止
 * </p>
 *
 * @author zql
 * @since 2019/9/19 13:16
 */
public class WindowStrategy implements CommandReqDtoStrategy {

  @Override
  public CommandDto make(CommandReqDto commandReqDto) {
    CommandDto commandDto = new CommandDto();
    commandDto.setVin(commandReqDto.getVin());
    commandDto.setIsRetry(commandReqDto.getIsRetry());

    commandDto.setCommand(CommandEnum.REMOTE_CONTROL.getFlag());
    commandDto.setControlCommand(RemoteControlEnum.WINDOW_CONTROL.getFlag());

    byte content = ExtendWindowEnum.DOWN.getFlag();
    if(commandReqDto.getOperateType() == OperateTypeEnum.CLOSE_WINDOW.getFlag()){
      content = ExtendWindowEnum.UP.getFlag();
    }else if(commandReqDto.getOperateType() == OperateTypeEnum.STOP_WINDOW.getFlag()){
      content = ExtendWindowEnum.STOP.getFlag();
    }

    commandDto.setControlContent(content);
    return commandDto;
  }
}
